package com.example.demo.controller;
import com.example.demo.model.Qx;
import com.example.demo.service.IQxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator 张喜英
 */

    @Api(tags = "qx")
    @RestController
    @RequestMapping("/swagger7")
    public class QxController {
        @Autowired
        private IQxService qxService;
    @CrossOrigin
    @ApiOperation(value="对权限信息的添加方法")
    @PostMapping("/insertqx")
    public int insertQx(@RequestBody Qx qx){
        System.out.println("进入添加权限接口" );
        return qxService.insertQx(qx);
    }

    @PostMapping("/getAll")
    public List<Qx> getAllQx(@RequestBody Qx qx)
    {
        System.out.println("进入查询方法");
        List<Qx> listQx=qxService.getAllQx(qx);
        return listQx;
    }
    @PostMapping("/editQx")
    public int EditQx(@RequestBody Qx qx){
        System.out.println("添加修改方法");
        return qxService.updateQx(qx);
}
    @GetMapping("/delQx")
    public int Delete(int qxid){
        System.out.println("进入删除方法");
        int returnValues=0;
        if(qxid!=0){
            Qx qx=new Qx();
            qx.setQxid(qxid);
        returnValues=qxService.deleteQx(qx);
        }
        return returnValues;
    }

    @GetMapping("/getOne")
    public Qx getQx(int qxid){
        Qx qx=new Qx();
        System.out.println("进入单条查询方法");
        if(qxid!=0){
            Qx qx1=new Qx();
            qx1.setQxid(qxid);
            qx=qxService.getQx(qx1);
            System.out.println("返回的数据集合为:"+qx.getQxid());
        }
        return qx;
    }








}
